package hibari.server.mail;

import hibari.client.model.DownloadToken;

import java.util.Properties;

import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;

public class Mailer {
	private DownloadMessageBuilder messageBuilder = new DownloadMessageBuilder();

	public Exception sendMail(DownloadToken token) {
		Properties props = new Properties();
		Session session = Session.getInstance(props);

		try {
			Message msg = this.messageBuilder.createMessage(token, session);
			Transport.send(msg);
			return null;
		} catch (Exception e) {
			e.printStackTrace();
			return e;
		}
	}

}
